package cn.edu.lingnan.test;

import java.sql.*;

public class JdbcDemo02 {
    public static void main(String[] args) {
        Connection conn=null;
        PreparedStatement prep=null;

        ResultSet rs=null;

        try {
            Class.forName("com.mysql.cj.jdbc.Driver");
            conn = DriverManager.getConnection
                    ("jdbc:mysql://localhost:3306/school","root","fA810233");
            prep=conn.prepareStatement("select * from student",
                    ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);
            rs=prep.executeQuery();
            System.out.println(rs.isFirst());
            System.out.println(rs.isBeforeFirst());
            while (rs.next()){

            }


        } catch (ClassNotFoundException e) {
            throw new RuntimeException(e);
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }finally {
            try {
                if (rs!=null)
                    rs.close();
                if (prep!=null)
                    prep.close();
                if (conn!=null)
                    conn.close();
            } catch (SQLException e) {
                throw new RuntimeException(e);
            }
        }
    }
}
